home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume22 / iozone / part01 next >
Encoding:
Text File  |  1991-08-21  |  20.3 KB  |  690 lines

  1. Newsgroups: comp.sources.misc
  2. From: Bill Norcott <norcott@databs.enet.dec.com>
  3. Subject:  v22i029:  iozone - sequential file I/O benchmark, Part01/01
  4. Message-ID: <1991Aug20.045631.29576@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 8ace420436d65b93d62264cc383fdc7a
  6. Date: Tue, 20 Aug 1991 04:56:31 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Bill Norcott <norcott@databs.enet.dec.com>
  10. Posting-number: Volume 22, Issue 29
  11. Archive-name: iozone/part01
  12. Environment: UNIX, VMS, DOS, OSF/1
  13. Supersedes: iozone: Volume 20, Issue 75
  14.  
  15. Attached is iozone.c V1.10.  This is the latest version of my portable
  16. benchmark of sequential file I/O.  This now supports over a dozen different
  17. hardware/OS combinations.
  18.  
  19. As always I welcome comments, your results from the 'iozone auto' test,
  20. and modifications #include statements for systems not yet supported by
  21. IOzone.
  22.  
  23. Regards,
  24. Bill Norcott
  25. -------
  26. #! /bin/sh
  27. # This is a shell archive.  Remove anything before this line, then feed it
  28. # into a shell via "sh file" or similar.  To overwrite existing files,
  29. # type "sh file -c".
  30. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  31. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  32. # Contents:  iozone.c
  33. # Wrapped by kent@sparky on Mon Aug 19 23:49:22 1991
  34. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  35. echo If this archive is complete, you will see the following message:
  36. echo '          "shar: End of archive."'
  37. if test -f 'iozone.c' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'iozone.c'\"
  39. else
  40.   echo shar: Extracting \"'iozone.c'\" \(18070 characters\)
  41.   sed "s/^X//" >'iozone.c' <<'END_OF_FILE'
  42. X/*
  43. X    iozone.c
  44. X
  45. X    'IO Zone' Benchmark Program
  46. X
  47. X    Author:    Bill Norcott (Bill.Norcott@nuo.mts.dec.com)
  48. X        4 Dunlap Drive
  49. X        Nashua, NH  03060
  50. X
  51. X    'Copyright 1991,   William D. Norcott
  52. X    License to freely use and distribute this software is hereby granted 
  53. X    by the author, subject to the condition that this copyright notice 
  54. X    remains intact.  The author retains the exclusive right to publish 
  55. X    derivative works based on this work, including, but not limited
  56. X    to, revised versions of this work'
  57. X*/
  58. Xchar *help[] = {
  59. X"     'IO Zone' Benchmark Program",
  60. X" ",
  61. X"     Author:    Bill Norcott (Bill.Norcott@nuo.mts.dec.com)",
  62. X"         4 Dunlap Drive",
  63. X"         Nashua, NH  03060",
  64. X" ",
  65. X"   'Copyright 1991,   William D. Norcott",
  66. X"   License to freely use and distribute this software is hereby granted ",
  67. X"   by the author, subject to the condition that this copyright notice ",
  68. X"   remains intact.  The author retains the exclusive right to publish ",
  69. X"   derivative works based on this work, including, but not limited ",
  70. X"   to, revised versions of this work'",
  71. X" ",
  72. X"  This test writes a 4 MEGABYTE sequential file in 512 byte chunks, then",
  73. X"  rewinds it  and reads it back.  [The size of the file should be",
  74. X"  big enough to factor out the effect of any disk cache.]",
  75. X"        ",
  76. X"  The file is written (filling any cache buffers), and then read.  If the",
  77. X"  cache is >= 4 MB, then most if not all the reads will be satisfied from",
  78. X"  the cache.  However, if it is less than or equal to 2 MB, then NONE of",
  79. X"  the reads will be satisfied from the cache.  This is becase after the ",
  80. X"  file is written, a 2 MB cache will contain the upper 2 MB of the test",
  81. X"  file, but we will start reading from the beginning of the file (data",
  82. X"  which is no longer in the cache)",
  83. X"        ",
  84. X"     NOTE: as of V1.04 default file size is now 1 MB not 4 MB",
  85. X"        ",
  86. X"  In order for this to be a fair test, the length of the test file must",
  87. X"  be AT LEAST 2X the amount of disk cache memory for your system.  If",
  88. X"  not, you are really testing the speed at which your CPU can read blocks",
  89. X"  out of the cache (not a fair test)",
  90. X"        ",
  91. X"  IOZONE does NOT test the raw I/O speed of your disk or system.  It",
  92. X"  tests the speed of sequential I/O to actual files.  Therefore, this",
  93. X"  measurement factors in the efficiency of you machines file system,",
  94. X"  operating system, C compiler, and C runtime library.  It produces a ",
  95. X"  measurement which is the number of bytes per second that your system",
  96. X"  can read or write to a file.  ",
  97. X" ",
  98. X"  For V1.06, IOZONE adds the 'auto test' feature.  This is activated",
  99. X"  by the command:  'iozone auto' .  The auto test runs IOZONE repeatedly  ",
  100. X"  using record sizes from 512 to 8192 bytes, and file sizes from 1 to 16",
  101. X"  megabytes.  It creates a table of results.",
  102. X"        ",
  103. X"  For V1.06, IOZONE lets you specify the number of file system sizes and      ",
  104. X"  record lengths to test when using auto mode.  Define the constants",
  105. X"  MEGABYTES_ITER_LIMIT and RECLEN_ITER_LIMIT as seen below      ",
  106. X"        ",
  107. X"  For V1.09 you can show the development help by typing 'iozone help'",
  108. X"        ",
  109. X"  For V1.10 IOzone traps SIGINT (user interrupt) and SIGTERM",
  110. X"  (kill from shell) signals and deletes the temporary file",
  111. X"        ",
  112. X"  This program has been ported and tested on the following computer",
  113. X"  operating systems:",
  114. X" ",
  115. X"    Vendor        Operating System    Notes on compiling IOzone",
  116. X"    -------------------------------------------------------------------------",
  117. X"    Convergent        Unisys/AT&T Sys5r3  cc -DCONVERGENT -o iozone iozone.c",
  118. X"    Digital Equipment    ULTRIX V4.1 ",    
  119. X"    Digital Equipment    VAX/VMS V5.4        see below **     ",
  120. X"    Digital Equipment    VAX/VMS (POSIX) ",
  121. X"    Hewlett-Packard    HP-UX 7.05",
  122. X"    IBM            AIX Ver. 3 rel. 1   cc -Dunix -o iozone iozone.c",
  123. X"    Microsoft        MS-DOS 3.3        tested Borland, Microsoft C",
  124. X"    OSF            OSF/1",
  125. X"    SCO            UNIX System V/386 3.2.2",
  126. X"    SCO            XENIX 3.2",
  127. X"    Silicon Graphics    UNIX            cc -DSGI -o iozone iozone.c",
  128. X"    Sun Microsystems    SUNOS 4.1.1",
  129. X"        ",
  130. X"    ** for VMS, define iozone as a foreign command via this DCL command:       ",
  131. X" ",
  132. X"     $IOZONE :== $SYS$DISK:[]IOZONE.EXE      ",
  133. X" ",
  134. X"     this lets you pass the command line arguments to IOZONE",
  135. X" ",
  136. X"  Acknowledgements to the following persons for their feedback on IOzone:       ",
  137. X" ",
  138. X"  Andy Puchrik, Michael D. Lawler, Krishna E. Bera, Sam Drake, John H. Hartman, ",
  139. X"  Ted Lyszczarz, Bill Metzenthen, Jody Winston, Clarence Dold",
  140. X"        ",
  141. X"  --- MODIFICATION HISTORY:",
  142. X" ",
  143. X" ",
  144. X"    3/7/91 William D. Norcott (Bill.Norcott@nuo.mts.dec.com)",
  145. X"         created",
  146. X" ",
  147. X"    3/22/91 Bill Norcott        tested on OSF/1 ... it works",
  148. X" ",
  149. X"    3/24/91 Bill Norcott        V1.02 -- use calloc in TURBOC to",
  150. X"                     fix bug with their malloc",
  151. X" ",
  152. X"    3/25/91 Bill Norcott        V1.03 -- add ifdef for XENIX",
  153. X"                     ",
  154. X"    3/27/91 Bill Norcott    V1.04 -- Includes for SCO UNIX",
  155. X"                     ",
  156. X"    4/26/91 Bill Norcott    V1.05 -- support AIX and SUNos, check",
  157. X"                     length of read() and write()",
  158. X"    4/26/91 Bill Norcott    V1.06 -- tabulate results of a series ",
  159. X"                     of tests",
  160. X"    5/17/91 Bill Norcott    V1.07 -- use time() for VMS",
  161. X"    5/20/91 Bill Norcott    V1.08 -- use %ld for Turbo C and",
  162. X"                     use #ifdef sun to bypass",
  163. X"                     inclusion of limits.h",
  164. X"    6/19/91 Bill Norcott    V1.09 -- rid #elif to support HP-UX and ",
  165. X"                     Silicon Graphics UNIX, and",
  166. X"                     add #ifdef SGI",
  167. X"                     add #ifdef CONVERGENT",
  168. X"                    for Convergent Technologies",
  169. X"                     also add help option",
  170. X"    7/2/91 Bill Norcott        V1.10 -- delete file if get SIGINT",
  171. X"                     or SIGTERM",
  172. X"" };
  173. X/******************************************************************
  174. X    INCLUDE FILES (system-dependent)
  175. X******************************************************************/
  176. X#include <signal.h>
  177. X#ifdef    __MSDOS__        /* Turbo C define this way for PCs... */
  178. X#define    MSDOS            /* Microsoft C defines this */
  179. X#endif
  180. X/* VMS and MS-DOS both have ANSI C compilers and use rand()/srand() */
  181. X#ifdef    VMS_POSIX
  182. X#undef   VMS
  183. X#define    ANSI_RANDOM    1
  184. X#endif
  185. X#ifdef    MSDOS
  186. X#define    ANSI_RANDOM    1
  187. X#endif
  188. X/* Convergent Technologies M680xx based with Unisys/AT&T Sys5r3 */
  189. X#ifdef CONVERGENT
  190. X#include <fcntl.h>
  191. X#define SysVtime
  192. X#endif 
  193. X/* incl definitions of O_* flags for XENIX */
  194. X#ifdef M_XENIX
  195. X#include <fcntl.h>
  196. X#endif
  197. X/* SCO Unix System V */
  198. X#ifdef M_UNIX
  199. X#include <sys/types.h>
  200. X#include <sys/fcntl.h>
  201. X#endif
  202. X#if defined(VMS)
  203. X#define    ANSI_RANDOM    1
  204. X#include    <math.h>
  205. X#include    <unixio.h>
  206. X#include    <ssdef.h>
  207. X#include    <file.h>
  208. X#include    <time.h>
  209. X#else
  210. X#ifdef MSDOS
  211. X/* #elif defined(MSDOS) */
  212. X#include <fcntl.h>
  213. X#include <time.h>
  214. X#endif
  215. X/* #elif defined(unix) */
  216. X#ifdef unix
  217. X#include <sys/file.h>
  218. X#ifndef NULL
  219. X#define NULL 0
  220. X#endif
  221. X#endif
  222. X/* 
  223. Xdefine nolimits if your system has no limits.h.  Sun's don't but I
  224. Xtake care of this explicitly beginning with V1.08 of IOzone.
  225. X*/
  226. X#ifdef sun
  227. X#define nolimits
  228. X#define BSDtime
  229. X#endif
  230. X/* V1.09 -- Silicon Graphics compile with -DSGI  */
  231. X#ifdef SGI
  232. X#define nolimits
  233. X#define BSDtime
  234. X#endif
  235. X#ifndef nolimits
  236. X#include <limits.h>
  237. X#endif
  238. X#endif
  239. X/* for systems with System V-style time, define SysVtime */
  240. X#ifdef M_SYSV
  241. X#define SysVtime
  242. X#endif
  243. X#ifdef SysVtime
  244. X#include <sys/times.h>
  245. X#include <sys/param.h>
  246. X#ifndef CLK_TCK
  247. X#define CLK_TCK HZ
  248. X#endif
  249. X#endif
  250. X/* for systems with BSD style time, define BSDtime */
  251. X#ifdef bsd4_2
  252. X#define BSDtime
  253. X#endif
  254. X#ifdef BSDtime
  255. X#include <sys/time.h>
  256. X#endif
  257. X/******************************************************************
  258. X    DEFINED CONSTANTS
  259. X******************************************************************/
  260. X#define MEGABYTES 1            /* number of megabytes in file */
  261. X#define RECLEN 512            /* number of bytes in a record */
  262. X#define FILESIZE (MEGABYTES*1024*1024)    /*size of file in bytes*/
  263. X#define NUMRECS FILESIZE/RECLEN        /* number of records */
  264. X#define MAXBUFFERSIZE 16*1024        /*maximum buffer size*/
  265. X#define MINBUFFERSIZE 128
  266. X#define TOOFAST 10
  267. X#define USAGE  "\tUsage:\tiozone [megabytes] [record_length_in_bytes] \
  268. X[[path]filename]\n\t\tiozone auto\n\t\tiozone help\n\n"
  269. X#define THISVERSION "V1.10"
  270. X/* Define only one of the following two.  All modern operating systems
  271. Xhave time functions so let TIME be defined */
  272. X#if 1
  273. X#define TIME 1
  274. X#else
  275. X#define NOTIME 1
  276. X#endif
  277. X
  278. X#define MAXNAMESIZE 1000                /* max # of characters in filename */
  279. X#define CONTROL_STRING1 "\t%-8ld%-8ld%-20ld%-20ld\n"
  280. X#define CONTROL_STRING2 "\t%-8s%-8s%-20s%-20s\n"
  281. X/* 
  282. X    For 'auto mode', these defines determine the number of iterations
  283. X    to perform for both the file size and the record length.
  284. X    I.e., if MEGABYTES_ITER_LIMIT = 5 use 1, 2, 4, 8 & 16 megabyte files
  285. X    if RECLEN_ITER_LIMIT = 5 use 512, 1024, 2048, 4096 & 8192 byte records
  286. X*/ 
  287. X#define MEGABYTES_ITER_LIMIT 5
  288. X#define RECLEN_ITER_LIMIT 5
  289. X/******************************************************************
  290. X    FUNCTION DECLARATIONS
  291. X******************************************************************/
  292. Xvoid auto_test();        /* perform automatic test series */
  293. Xvoid show_help();        /* show development help*/
  294. Xstatic double time_so_far();    /* time since start of program */
  295. Xvoid signal_handler();        /* clean up if user interrupts us */
  296. X/******************************************************************
  297. X    GLOBAL VARIABLES
  298. X******************************************************************/
  299. Xint auto_mode;
  300. Xchar filename [MAXNAMESIZE];            /* name of temporary file */
  301. X/******************************************************************
  302. X    MAIN -- entry point
  303. X******************************************************************/
  304. Xmain(argc,argv) 
  305. X      int argc;
  306. X     char *argv[];
  307. X{
  308. Xint fd;
  309. Xchar *default_filename="iozone.tmp"; /*default name of temporary file*/
  310. X#ifdef    MSDOS
  311. Xchar *buffer; 
  312. X#else
  313. Xchar buffer [MAXBUFFERSIZE];        /*a temporary data buffer*/
  314. X#endif
  315. Xint i, status;
  316. Xunsigned long megabytes = MEGABYTES, goodmegs;
  317. Xunsigned long reclen = RECLEN, goodrecl;
  318. Xunsigned long filesize = FILESIZE;
  319. Xunsigned long numrecs = NUMRECS;
  320. Xunsigned long filebytes;
  321. Xunsigned long readrate, writerate;
  322. X#ifdef TIME
  323. X double starttime1, starttime2;
  324. X double writetime, readtime;
  325. X double totaltime;
  326. X#endif
  327. X#ifdef MSDOS
  328. X  buffer = (char *) calloc(1, MAXBUFFERSIZE);
  329. X#endif
  330. X  if (!auto_mode)
  331. X  {
  332. X    printf("\n\tIOZONE: Performance Test of Sequential File I/O  --  %s\n",
  333. X          THISVERSION);
  334. X    printf("\t\tBy Bill Norcott\n\n");
  335. X
  336. X    signal(SIGINT, signal_handler);     /* handle user interrupt */
  337. X    signal(SIGTERM, signal_handler);     /* handle kill from shell */
  338. X  }
  339. X  strcpy(filename,default_filename);
  340. X  switch (argc) {
  341. X    case 1:       /* no args, take all defaults */
  342. X      printf(USAGE);
  343. X    break;
  344. X    case 2:     /* <megabytes|filename> */
  345. X    i = atoi(argv[1]); if (i) {
  346. X      megabytes = i;
  347. X    } else {
  348. X/*
  349. X'Auto mode' will be enabled if the first command line argument is
  350. Xthe word 'auto'.  This will trigger a series of tests
  351. X*/
  352. X      if ( (strcmp(argv[1], "auto") == 0) || 
  353. X           (strcmp(argv[1], "AUTO") == 0) )
  354. X      {
  355. X        auto_mode = 1;
  356. X        auto_test();
  357. X        printf("Completed series of tests\n");
  358. X        exit(0);
  359. X      } else {
  360. X        auto_mode = 0;
  361. X      }
  362. X      if ( (strcmp(argv[1], "help") == 0) || 
  363. X           (strcmp(argv[1], "HELP") == 0) )
  364. X      {
  365. X        show_help();
  366. X        exit(0);
  367. X      }
  368. X      strcpy(filename,argv[1]);
  369. X        }
  370. X    break;
  371. X    case 3:     /* <megabytes> <reclen|filename> */
  372. X    megabytes = atoi(argv[1]);
  373. X    if (atoi(argv[2])) {
  374. X      reclen = atoi(argv[2]);
  375. X    } else {
  376. X      strcpy(filename,argv[2]);
  377. X    }
  378. X    break;
  379. X    case 4:     /* <megabytes> <reclen> <filename> */
  380. X    megabytes = atoi(argv[1]);
  381. X    reclen = atoi(argv[2]);
  382. X    strcpy(filename,argv[3]);
  383. X    break;
  384. X    default:
  385. X      printf("IOZONE: bad usage\n");
  386. X      printf(USAGE);
  387. X      exit(1);
  388. X  }
  389. X  if (!auto_mode)
  390. X  {
  391. X    printf("\tSend comments to:\tBill.Norcott@nuo.mts.dec.com\n\n");
  392. X  }
  393. X  filesize = megabytes*1024*1024;
  394. X  numrecs = filesize/reclen;
  395. X  if (reclen >  MAXBUFFERSIZE) {
  396. X    printf("Error: Maximum record length is %d bytes\n", MAXBUFFERSIZE);
  397. X        exit(1);
  398. X    }
  399. X  if (reclen < MINBUFFERSIZE) {
  400. X    printf("Error: Minimum record length is %d bytes\n", MINBUFFERSIZE);
  401. X        exit(1);
  402. X    }
  403. X  if (!auto_mode)
  404. X  {
  405. X    printf("\tIOZONE writes a %ld Megabyte sequential file consisting of\n",
  406. X    megabytes);
  407. X    printf("\t%ld records which are each %ld bytes in length.\n",
  408. X    numrecs, reclen);
  409. X    printf("\tIt then reads the file.  It prints the bytes-per-second\n");
  410. X    printf("\trate at which the computer can read and write files.\n\n");
  411. X    printf("\nWriting the %ld Megabyte file, '%s'...", megabytes, filename);
  412. X  }  
  413. X    if((fd = creat(filename, 0640))<0){
  414. X        printf("Cannot create temporary file: %s\n", filename);
  415. X        exit(1);
  416. X    }
  417. X#ifdef TIME
  418. X    starttime1 = time_so_far();
  419. X#endif
  420. X    for(i=0; i<numrecs; i++){
  421. X#ifndef DEBUG_ME
  422. X        if(write(fd, buffer, (unsigned) reclen) != reclen)
  423. X            {
  424. X            printf("Error writing block %d\n", i);
  425. X            exit(1);
  426. X            }
  427. X#endif
  428. X    }
  429. X#ifdef TIME
  430. X    writetime = time_so_far() - starttime1;
  431. X    if (!auto_mode)
  432. X        {
  433. X        printf("%f seconds", writetime);
  434. X        }
  435. X#endif
  436. X    close(fd);
  437. X#if defined (VMS)
  438. X    if((fd = open(filename, O_RDONLY, 0640))<0){
  439. X        printf("Cannot open temporary file for read\n");
  440. X        exit(1);
  441. X    }
  442. X#else
  443. X#ifdef MSDOS
  444. X/* #elif defined(MSDOS) */
  445. X    if((fd = open(filename, O_RDONLY, 0640))<0){
  446. X        printf("Cannot open temporary file for read\n");
  447. X        exit(1);
  448. X    }
  449. X#else
  450. X    if((fd = open(filename, O_RDONLY))<0){
  451. X        printf("Cannot open temporary file for read\n");
  452. X        exit(1);
  453. X       }
  454. X#endif
  455. X#endif
  456. X            /*start timing*/
  457. X#if defined(NOTIME)
  458. X    printf("start timing\n");
  459. X#endif
  460. X    if (!auto_mode)
  461. X    {
  462. X        printf("\nReading the file...");
  463. X    }
  464. X    starttime2 = time_so_far();
  465. X   for(i=0; i<numrecs; i++) {
  466. X#ifndef DEBUG_ME
  467. X    if(read(fd, buffer, (unsigned) reclen) != reclen)
  468. X    {
  469. X        printf("Error reading block %d\n", i);
  470. X        exit(1);
  471. X    }
  472. X#endif
  473. X    }
  474. X#ifdef NOTIME
  475. X    printf("stop timing\n");
  476. X#endif
  477. X#ifdef TIME
  478. X    readtime = time_so_far() - starttime2;
  479. X    if (!auto_mode)
  480. X    {
  481. X        printf("%f seconds\n", readtime);
  482. X    }
  483. X#ifdef DEBUG_ME
  484. X    readtime = 1;
  485. X    writetime = 1;
  486. X#endif
  487. X    if(readtime!=0)
  488. X    {   
  489. X        filebytes = numrecs*reclen;
  490. X        readrate = (unsigned long) ((double) filebytes / readtime);
  491. X        writerate = (unsigned long) ((double) filebytes / writetime);
  492. X        if (auto_mode)
  493. X        {
  494. X         printf(CONTROL_STRING1,
  495. X            megabytes, 
  496. X            reclen,
  497. X            writerate,
  498. X            readrate);
  499. X                    
  500. X        } else {
  501. X        printf("\nIOZONE performance measurements:\n");
  502. X        printf("\t%ld bytes/second for writing the file\n", writerate);
  503. X        printf("\t%ld bytes/second for reading the file\n", readrate);
  504. X        totaltime = readtime + writetime;
  505. X        if (totaltime < TOOFAST) 
  506. X        {
  507. X            goodmegs = (TOOFAST/totaltime)*2*megabytes;
  508. X            printf("\nThe test completed too quickly to give a good result\n");
  509. X            printf("You will get a more precise measure of this machine's\n");
  510. X            printf("performance by re-running IOZONE using the command:\n");
  511. X            printf("\n\tiozone %ld ", goodmegs);
  512. X            printf("\t(i.e., file size = %ld megabytes)\n", goodmegs);
  513. X        }
  514. X        }
  515. X    } else {
  516. X        goodrecl = reclen/2;
  517. X        printf("\nI/O error during read.  Try again with the command:\n");
  518. X        printf("\n\tiozone %ld %ld ", megabytes,  goodrecl);
  519. X        printf("\t(i.e. record size = %ld bytes)\n",  goodrecl);
  520. X    }
  521. X#endif
  522. X    close(fd);
  523. X#ifndef VMS
  524. X    unlink(filename);    /* delete the file */
  525. X                    /*stop timer*/
  526. X#endif
  527. X#ifdef    MSDOS
  528. X    free(buffer);        /* deallocate the memory */
  529. X#endif
  530. X#ifdef VMS
  531. Xreturn SS$_NORMAL;
  532. X#else
  533. Xreturn 0;
  534. X#endif
  535. X}
  536. X/******************************************************************
  537. X    SHOW_HELP -- show development help of this program
  538. X******************************************************************/
  539. Xvoid show_help()
  540. X{
  541. X    int i;
  542. X    printf("IOZONE: help mode\n\n");
  543. X    for(i=0; strlen(help[i]); i++)
  544. X    {
  545. X    printf("%s\n", help[i]);
  546. X    }
  547. X}
  548. X/******************************************************************
  549. X    SIGNAL_HANDLER -- clean up if user interrupts the program
  550. X******************************************************************/
  551. Xvoid signal_handler()
  552. X{
  553. X    int i;
  554. X    printf("\nIOZONE: interrupted\n\n");
  555. X#ifndef VMS
  556. X    printf("deleting file: %s\n", filename);
  557. X    unlink(filename);    /* delete the file */
  558. X#endif
  559. X    printf("exiting IOzone\n\n");
  560. X    exit();
  561. X}
  562. X/******************************************************************
  563. X    AUTO_TEST -- perform series of tests and tabulate results
  564. X******************************************************************/
  565. Xvoid auto_test()
  566. X{
  567. X    int megsi, recszi;
  568. X    char megs[10]; 
  569. X    char recsz[10];
  570. X    int i,j;
  571. X    int argc = 3;
  572. X    char *argv[3];
  573. X    
  574. X    printf("IOZONE: auto-test mode\n\n");
  575. X    printf(CONTROL_STRING2,
  576. X    "MB", 
  577. X    "reclen",
  578. X    "bytes/sec written",
  579. X    "bytes/sec read");
  580. X    argv[0] = "IOzone auto-test";
  581. X    argv[1] = megs;
  582. X    argv[2] = recsz;
  583. X/*
  584. XStart with file size of 1 megabyte and repeat the test MEGABYTES_ITER_LIMIT
  585. Xtimes.  Each time we run, the file size is doubled
  586. X*/
  587. X    for(i=0,megsi=1;i<MEGABYTES_ITER_LIMIT;i++,megsi*=2) 
  588. X    {
  589. X    sprintf(megs, "%d", megsi);
  590. X/*
  591. XStart with record size of 512 bytes and repeat the test RECLEN_ITER_LIMIT
  592. Xtimes.  Each time we run, the record size is doubled
  593. X*/
  594. X    for (j=0,recszi=512;j<RECLEN_ITER_LIMIT;j++,recszi*=2)
  595. X    {
  596. X        sprintf(recsz, "%d", recszi);
  597. X        main(argc, argv);
  598. X    }
  599. X    }
  600. X}
  601. Xstatic double
  602. Xtime_so_far()
  603. X{
  604. X#if defined(VMS)
  605. X/* 
  606. X*   5/17/91 Bill Norcott    V1.07 -- use time() for VMS
  607. XThe times() function in VMS returns proc & user CPU time in 10-millisecond
  608. Xticks.  Instead, use time() which lacks the precision but gives clock
  609. Xtime in seconds.
  610. X*/
  611. X  return (double) time(NULL);
  612. X#else
  613. X#ifdef SysVtime
  614. X/* #elif defined(SysVtime) */
  615. X  int        val;
  616. X  struct tms tms;
  617. X  if ((val = times(&tms)) == -1)
  618. X    perror("times");
  619. X  return ((double) val) / ((double) CLK_TCK);
  620. X#endif
  621. X#if defined(MSDOS)
  622. X  return ((double) clock()) / ((double) CLK_TCK);
  623. X#endif
  624. X#ifndef MSDOS
  625. X#ifndef SysVtime
  626. X/* #else */
  627. X  struct timeval tp;
  628. X  if (gettimeofday(&tp, (struct timezone *) NULL) == -1)
  629. X    perror("gettimeofday");
  630. X  return ((double) (tp.tv_sec)) +
  631. X    (((double) tp.tv_usec) / 1000000.0);
  632. X#endif
  633. X#endif
  634. X#endif
  635. X}
  636. X
  637. END_OF_FILE
  638.   if test 18070 -ne `wc -c <'iozone.c'`; then
  639.     echo shar: \"'iozone.c'\" unpacked with wrong size!
  640.   fi
  641.   # end of 'iozone.c'
  642. fi
  643. echo shar: End of archive.
  644. exit 0
  645. exit 0 # Just in case...
  646. -- 
  647. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  648. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  649. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  650. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  651.